<?php

/**
* @current fronteffectlibrary.php
* @author   LiuYang <liu_yang@haibao.com>
* @date 2016年8月1日 下午2:35:55
*/

namespace haibao\cms\data;

use haibao\cms\model\filter\FrontEffectLibrary as FrontEffectLibraryFilter;

class FrontEffectLibrary extends \haibao\cms\data\BaseMysql{
	
	public function __construct(){
		parent::__construct('\haibao\cms\model\data\FrontEffectLibrary');
	}
	
	function addFrontEffectLibrary($model){
        $this->beginTranscation();
        try{
            $this->add($model);
        } catch(\Exception $e){
            throw $e;
        }
        $this->endtranscation();
        return $model;
	}
	
	function editFrontEffectLibrary($model){
	    $frontEffectLibraryModel = $this->packFrontEffectLibraryModelFilter($model);
	    $this->beginTranscation();
	    try{
	        $this->updateById($model->Id,$frontEffectLibraryModel);
	    } catch(\Exception $e){
	        throw $e;
	    }
	    $this->endtranscation();
	}
	
	function packFrontEffectLibraryModelFilter($model){
	    $frontEffectLibraryFilter = new FrontEffectLibraryFilter;
	    $frontEffectLibraryFilter = array(
	        FrontEffectLibraryFilter::CONDITION_FIELD_NAME_EFFECT_TITLE =>$model->EffectTitle,
	        FrontEffectLibraryFilter::CONDITION_FIELD_NAME_EFFECT_URL =>$model->EffectUrl,
	        FrontEffectLibraryFilter::CONDITION_FIELD_NAME_EFFECT_DESC =>$model->EffectDesc,
	        FrontEffectLibraryFilter::CONDITION_FIELD_NAME_EFFECT_KEYWORDS =>$model->EffectKeywords,
	        FrontEffectLibraryFilter::CONDITION_FIELD_NAME_STATUS =>$model->Status,
	        FrontEffectLibraryFilter::CONDITION_FIELD_NAME_CREATEBY =>$model->CreateBy,
	        FrontEffectLibraryFilter::CONDITION_FIELD_NAME_CREATETIME =>$model->CreateTime,
	    );
	    return $frontEffectLibraryFilter;
	}
}
